package utils;

import java.util.Collections;
import java.util.List;

/**
 * Created by TX on 2016/10/17 14:55
 * Class Note:
 */
public class DayFormatUtil {


    /**
     * 处理营业日、生成用于显示的营业日信息
     *
     * @param officeDays
     * @return
     */
    public static String generateDayStr(List<Integer> officeDays) {
        String dayStr = "";
        if (officeDays != null) {
            if (officeDays.size() == 7) {
                dayStr = "每天";
            } else if (officeDays.size() == 5 && !officeDays.contains(6) && !officeDays.contains(6)) {
                dayStr = "周末不营业";
            } else if (officeDays.size() == 0) {
                dayStr = "";
            } else {
                Collections.sort(officeDays);
                for (int i = 0; i < officeDays.size(); i++) {
                    dayStr += formatDay(officeDays.get(i));
                }
                dayStr = dayStr.substring(0, dayStr.length() - 1);
            }


        }
        return dayStr;
    }

    /**
     * 生成对应的星期日
     *
     * @param integer
     * @return
     */
    private static String formatDay(Integer integer) {
        String day = "";
        switch (integer) {
            case 1: {
                day = "周一、";
            }
            break;
            case 2: {
                day = "周二、";
            }
            break;
            case 3: {
                day = "周三、";
            }
            break;
            case 4: {
                day = "周四、";
            }
            break;
            case 5: {
                day = "周五、";
            }
            break;
            case 6: {
                day = "周六、";
            }
            break;
            case 7: {
                day = "周日、";
            }
            break;
            default:
                break;
        }
        return day;
    }
}
